home *** CD-ROM | disk | FTP | other *** search
- Path: columba.udac.uu.se!not-for-mail
- From: trulsson@student.docs.uu.se (Erik Trulsson)
- Newsgroups: comp.lang.c
- Subject: Re: How can I use huge || very small number?
- Date: 3 Apr 1996 17:46:34 GMT
- Organization: Uppsala Universitet
- Message-ID: <4judhq$1vf6@columba.udac.uu.se>
- References: <315681F3.314D@blue.nowcom.co.kr> <4joh0l$jch@news.acns.nwu.edu> <4jpep5$db2@penage.cs.laurentian.ca>
- NNTP-Posting-Host: minsk.docs.uu.se
- X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
-
- Edward C. Chan (echan@nickel.laurentian.ca) wrote:
- > >>may be it is FAQ but...
- > >>how can I compute 10000! or 0.12345......
- > >
- > >10000! is a very, very big number.
- > >I'm not sure it's even representable by standard IEEE fp notation.
- > >Any have that formula? 2*pi*e something or another.
- >
- > I don't think 10000! will fit a long double. So why not store it on
- > an array (or a linked list) of longs?
-
- It won't fit into any standard data type. What you will have to do is
- to represent the numbers as strings of digits and do all the operations
- yourself. (Very much like you do when calculating on paper.)
- This approach is a lot slower than using the builtin data types but
- you can use arbitrarily large numbers.
-
- >
- > As for small numbers, most commercially-available compilers are cacable
- > of near-infinite precision when optimized (i.e. no debugging info.) As
- > far as I know, Watcom has the highest floating-point precision. Again, the
- > same principle I described above will also help.
- >
-
- If you use the standard data types (i.e. float or double) and your system uses
- the IEEE standard for floating point (which most systems do these days)
- the there are limits.
- A single precision number (float) has about seven digits of precision and the
- smallest representable number is about 1E-38, for a double the values are
- 15 digits and 1E-308 instead.
- If you want better precision you will have to do it on your own in a similar
- way as for big numbers.
-
-